﻿Module GenericAdministrator

    Public Sub insert(ByRef obj As GenericObject)
        GenericDao.insert(obj)
    End Sub

    Public Sub update(ByRef obj As GenericObject)
        GenericDao.update(obj)
    End Sub

    Public Function searchDataByFilter(ByRef obj As GenericObject) As Data.DataTable
        Return GenericDao.searchDataByFilter(obj)
    End Function
    ' JFabro. 10/10/2011
    Public Function searchDataById(ByRef obj As GenericObject) As GenericObject
        Return GenericDao.searchDataById(obj)
    End Function

    Public Sub deletedById(ByRef obj As GenericObject)
        GenericDao.deleteById(obj)
    End Sub

    Public Sub loadComboBox(ByRef combo As ComboBox, ByRef table As Data.DataTable, ByVal id As String, ByVal description As String)
        Util.cleanComboBox(combo)
        combo.DataSource = table
        combo.ValueMember = id
        combo.DisplayMember = description
    End Sub

    Public Sub loadListBox(ByRef listBox As ListBox, ByRef table As Data.DataTable, ByVal id As String, ByVal description As String)
        listBox.Items.Clear()
        listBox.DataSource = table
        listBox.ValueMember = id
        listBox.DisplayMember = description
    End Sub

    Public Sub loadGrid(ByRef grid As DataGridView, ByRef bindingNavigator As BindingNavigator, ByRef table As Data.DataTable)
        Dim bs As New BindingSource
        bs.DataSource = table
        bindingNavigator.BindingSource = bs
        grid.DataSource = bs
    End Sub

    Public Sub loadNavigator(ByRef navigator As BindingNavigator, ByRef source As BindingSource)
        navigator.BindingSource = source
    End Sub

End Module
